/**
 * request zz
 * params data
 *
 * */
export default function request({data, url = '', method, success = () => {}, error = () => {}, complete = () => {}}) {
    var phone = wx.getStorageSync('phone')
	data.userPhone = phone
    uni.request({
        url: url,
        data: data,
        method: method, // OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, CONNECT
        header: {
            'content-type': 'application/json'
        },
        success: (request) => {
            switch (request.data.code) {
                case 0:
                    success(request.data.result);
                    break;
				case 1:
					error(request.data.msg || '未知错误');
					break;
                default:
                    if (error) {
                        error(request.data.msg || '未知错误');
                    } else {
                        uni.showToast({
                            icon: 'none',
                            duration: 2000,
                            title: request.data.msg || '未知错误'
                        })
                    }
            }
        },
        fail: error,
        complete: complete
    })
}